package com.surfacing.rcp.client.editors;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPersistableElement;

import com.surfacing.rcp.model.entity.Transportziel;

public class TransportzielEditorInput implements IEditorInput {
	// properties
	private Transportziel transportziel;
	private boolean isNew;

	/**
	 * Default class constructor for the staff member editor.
	 * 
	 * @param transportziel
	 *            the transportziel to edit
	 * @param login
	 *            the login information accociated with the staff member
	 * @param isNew
	 *            a flag to determine whether the member is new
	 */
	public TransportzielEditorInput(Transportziel transportziel, boolean isNew) {
		this.transportziel = transportziel;
		this.isNew = isNew;
	}

	@Override
	public boolean exists() {
		return false;
	}

	@Override
	public ImageDescriptor getImageDescriptor() {
		return null;
	}

	@Override
	public String getName() {
		if (isNew)
			return "Neues Transportziel";
		return transportziel.getTransportziel();
	}

	@Override
	public IPersistableElement getPersistable() {
		return null;
	}

	@Override
	public String getToolTipText() {
		return "Transportziel: " + transportziel.getTransportziel();
	}

	@Override
	@SuppressWarnings("unchecked")
	public Object getAdapter(Class arg0) {
		return null;
	}

	@Override
	public boolean equals(Object other) {
		if (other instanceof TransportzielEditorInput) {
			TransportzielEditorInput otherEditor = (TransportzielEditorInput) other;
			return transportziel.equals(otherEditor.getTransportziel());
		}
		return false;
	}

	@Override
	public int hashCode() {
		return transportziel.hashCode();
	}

	/**
	 * Returns the staff member
	 * 
	 * @return the staff member
	 */
	public Transportziel getTransportziel() {
		return transportziel;
	}

	/**
	 * Returns whether or not the staff member is new.
	 * 
	 * @return true if the staff member is created new
	 */
	public boolean isNew() {
		return isNew;
	}
}
